package com.kupurui.asteacher.adapter;

import android.content.Context;
import android.text.Html;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.android.frame.adapter.CommonAdapter;
import com.android.frame.adapter.ViewHolder;
import com.kupurui.asteacher.R;
import com.kupurui.asteacher.bean.JobAnalysisInfo;
import com.kupurui.asteacher.utils.URLImageParser;

import java.util.List;

/**
 * Created by Administrator on 2017/9/6.
 */

public class AnalysisRadioAdapter extends CommonAdapter<JobAnalysisInfo.OptionBean> {


    public AnalysisRadioAdapter(Context context, List<JobAnalysisInfo.OptionBean> mList, int itemLayoutId) {
        super(context, mList, itemLayoutId);
    }

    @Override
    public void convert(ViewHolder holder, JobAnalysisInfo.OptionBean item, int positon) {
        LinearLayout llItem = holder.getView(R.id.ll_item);
        TextView tvRadio = holder.getView(R.id.tv_radio);
        TextView tvOption = holder.getView(R.id.tv_option);
        tvOption.setText(item.getXuanxiang());
        tvRadio.setText(Html.fromHtml(item.getAnswer(), new URLImageParser(mContext,tvRadio), null));

        if (item.getIs_true().equals("1")){
            llItem.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.shape_round_white_green_5));
            tvOption.setBackgroundColor(mContext.getResources().getColor(R.color.tab_color));
            tvOption.setTextColor(mContext.getResources().getColor(R.color.white));
        }else if (item.getIs_true().equals("3")){
            llItem.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.shape_round_white_red_5));
            tvOption.setBackgroundColor(mContext.getResources().getColor(R.color.fbtn_red));
            tvOption.setTextColor(mContext.getResources().getColor(R.color.white));
        }
    }
}
